<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>用户注册</h2>
    <form onsubmit="return validateForm()">
        <label for="yong">用户名: </label><input type="text" id="yong"><br>
        <label for="you">邮箱: </label><input type="email" id="you"><br>
        <label for="mi">密码: </label><input type="password" id="mi"><br>
        <input type="submit">
    </form> 
    <script>
            function validateForm() {
            var yong = document.getElementById("yong").value;
            var you = document.getElementById("you").value;
            var mi = document.getElementById("mi").value;

            // 用户名验证
            if (yong.length < 3) {
                alert("用户名必须至少3个字符");
                return false;
            }

            // 密码验证
            if (mi.length < 6) {
                alert("密码必须至少6个字符");
                return false;
            }

            // 邮箱验证
            var you = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
            if (!you.test(email)) {
                alert("请输入有效的邮箱！");
                return false;
            }

            return true;
        }
    </script>
</body>
</html>